package cn.kuick.iplocation.jdk_proxy_study;

import java.lang.Object;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by Administrator on 2016/11/29.
 */
public class ProxyHandler implements InvocationHandler {
    private Object concreteClass;

    public ProxyHandler(Object concreteClass){
        this.concreteClass = concreteClass;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable{
        System.out.println("proxy:" + proxy.getClass().getName());
        System.out.println("method:" + method.getName());
        System.out.println("args:" +args[0].getClass().getName());

        System.out.println("Before invoke method......");
        Object object = method.invoke(concreteClass, args);

        System.out.println("After invoke method......");
        return object;
    }
}
